<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link th:href="@{/css/style.css}" rel="stylesheet" type="text/css" />
<script type="text/javascript" th:src="@{/js/jquery.js}"></script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>仓库管理</li>
    <li>仓库管理</li>
    <li>添加仓库</li>
  </ul>
</div>
<div class="formbody">
    <form th:action="@{/storage/save}" method="post">
  <div class="formtitle"><span>仓库信息</span></div>
  <ul class="forminfo">
    <li>
      <label>仓库名称</label>
      <input name="cName" type="text" class="dfinput" />
      <i>必填，不能超过30个字符</i>
    </li>
    <li>
      <label>仓库地址</label>
      <input name="cAddress" type="text" class="dfinput" />
      <i>必填，不能超过300个字符</i>
    </li>
    <li>
      <label>所属区域</label>
      <select class="dfselect" name="provinceId" onchange="ajaxProvince(this.value)">
          <option>请选择</option>
          <option th:each="pv :${session.plist}" th:value="${pv.id}" th:text="${pv.pName}"></option>
      </select>
      省
      <select class="dfselect" name="cityId">
          <option value="0">请选择</option>
      </select>
      市
      <i>必选</i>
    </li>
    <li>
      <label>负责人</label>
      <select class="dfselect" name="usreId">
          <option value="">请选择</option>
          <option th:each="u :${session.glUsers}" th:value="${u.uId}" th:text="${u.uname}"></option>
      </select>
       <i>只能是财务部仓库管理员职位</i>
    </li>
    <li>
      <label>联系方式</label>
      <input name="phone" type="text" class="dfinput" />
       <i>必填，不能超过30个字符</i>
    </li>
    <li>
      <label>描述</label>
      <textarea class="textinput" name="details"></textarea>
      <i>可选</i>
    </li>
    <li>
      <label>状态</label>
      <select class="dfselect" name="state">
          <option value="1">可用</option>
          <option value="2">不可用</option>
        </select>
      <i>必选</i>
    </li>
    <li>
      <label>创建人id</label>
      <input name="usersId" th:value="${session.users.uId}"  type="text" readonly="readonly" class="roinput" />
      <i>不能编辑</i>
    </li>
    <li>
      <label>&nbsp;</label>
      <input name="" type="submit" class="btn" value="确定"/>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <input name="" type="button" class="btn" value="返回" onclick="history.go(-1)"/>
    </li>
  </ul>
</form>
</div>
<script>

  // 省市级联
  function ajaxProvince(pid){
    $.get("/erp/storage/ajaxProvince",{"pid":pid},function (data) {
      $("select[name=cityId]").html();  // 清空

      var str = "<option value=''>请选择城市</option>";
      $.each(data,function (i,e) {
        str += "<option value="+e.id+">"+e.cname+"</option>";
      });
      $("select[name=cityId]").html(str);  // 添加元素

    },"json");
  }
</script>
</body>
</html>
